package day06;

import java.util.Arrays;

public class Exercise02 {
    public static void main(String[] args) {
        /*//1. MaxOfArray求数组元素最大值并放在最后一个元素的下一个位置
        int[] arr = new int[20];
        for (int i = 0; i < arr.length; i++) {
            arr[i]=(int) (Math.random()*1000);
            System.out.print(arr[i]+"\t");
        }

        System.out.println();
        int max = arr[0];
        for (int i = 1; i <arr.length; i++) {
            if (max <= arr[i]) {
                max = arr[i];
            }
        }
        System.out.println("数组的最大值为:"+max);
        arr = Arrays.copyOf(arr,arr.length+1);
        arr[arr.length-1] = max;
        for (int i = 0; i <arr.length; i++) {
            System.out.print(arr[i]+"\t");
        }
         */
        //方法的练习:
        method01();
        method02(2);
        method03("WXY",3);
        double a = method4();
        System.out.println("第4个方法的结果为:"+a);
        int b = method05(2,6);
        System.out.println("第5个方法的结果为:"+b);
        int[] c = method06(8,100);
        System.out.println("第6个方法生成的数组长度为"+c.length);
        for (int i = 0; i <c.length ; i++) {
            System.out.print(c[i]+"\t");
        }

    }
    public static void method01(){
        System.out.println("无参数无返回值方法");
    }
    public static void method02(int x){
        System.out.println("第"+x+"个方法，有一参数无返回值");
    }
    public static void method03(String name,int q){
        System.out.println("第"+q+"个方法，有两个参数无返回值"+name);
    }
    public static double method4(){
        return 4.0;
    }
    public static int method05(int m,int n){
        int num = m * n;
        return num;
    }
    public static int[] method06(int len,int max){
        int[] arr = new int[len];
        for (int i = 0; i <arr.length ; i++) {
            arr[i] = (int)(Math.random()*max);
        }
        return arr;
    }
}
